<template>
    <a-form ref="formRef" :model="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }">
        <a-form-item label="类名" :rules="rules.name" name="name">
            <a-input v-model:value="form.name" :disabled="disabled" placeholder="请输入类名" />
        </a-form-item>
        <a-form-item label="数据权限" :rules="rules.authority" name="authority">
            <dict-radio v-model:value="form.authority" dict-code="authority" />
        </a-form-item>
    </a-form>
</template>
<script setup>
import { ref, computed, reactive } from 'vue'
import { useForm } from '@iframe/tools/mixins/FormMixins'
import { DictRadio } from '@iframe/tools/components'

const { validate, getForm, setForm } = useForm()
const formRef = ref()
const form = reactive({})
const rules = reactive({
    name: { required: true, message: '请输入类名' },
    authority: { required: true, message: '请选择数据权限' }
})

const disabled = computed(() => {
    return !!form.id
})

defineExpose({ validate: validate(formRef), getForm: getForm(form), setForm: setForm(form) })
</script>
